package qgs.zisu.javaconcurrency.javaconcurrency.chapter8_DeadLock;

/**
 * @Author: 蔡翔
 * @Date: 2019/10/12 19:43
 * @Version 1.0
 *
 * 死锁--两个线程共同持有一个锁，并且等待彼此线程的锁。
 */
public class DeadLockTest {
    public static void main(String[] args) {
        OtherService otherService = new OtherService();
        DeadLock deadLock = new DeadLock(otherService);
        otherService.setDeadLock(deadLock);

        new Thread(){
            @Override
            public void run(){
                while (true){
                    otherService.s2();
                }
            }
        }.start();

        new Thread(){
            @Override
            public void run(){
                while (true){
                    deadLock.m1();
                }
            }
        }.start();
    }
}
